/**
 * @author zhoushengtao
 * @since 2012-8-30 下午4:10:11
 */

package com.stchou.superbrowser.ui.widget;

import com.stchou.superbrowser.activity.R;

import android.graphics.Bitmap;
import android.os.Message;
import android.view.View;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.widget.ProgressBar;

public class SuperWebviewChromeClient extends WebChromeClient
{

    private ProgressBar m_progressBar;
    private SuperImageButton m_stopButton;
    /**
     * @param progressBar
     * @param stopButton 
     */
    public SuperWebviewChromeClient(ProgressBar progressBar, SuperImageButton stopButton)
    {
        m_progressBar = progressBar;
        m_stopButton = stopButton;
    }

    @Override
    public View getVideoLoadingProgressView()
    {
        return super.getVideoLoadingProgressView();
    }

    @Override
    public void onCloseWindow(WebView window)
    {

        super.onCloseWindow(window);
    }

    @Override
    public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture, Message resultMsg)
    {

        return super.onCreateWindow(view, isDialog, isUserGesture, resultMsg);
    }

    @Override
    public boolean onJsAlert(WebView view, String url, String message, JsResult result)
    {
        return super.onJsAlert(view, url, message, result);
    }

    @Override
    public void onProgressChanged(WebView view, int newProgress)
    {
        super.onProgressChanged(view, newProgress);
        if (newProgress == 100)
        {
            m_progressBar.setVisibility(View.GONE);
            m_stopButton.setImageResource(R.drawable.bottombar_previous_normal);
        }
        else
        {
            m_progressBar.setVisibility(View.VISIBLE);
            m_progressBar.setProgress(newProgress);
            m_stopButton.setImageResource(R.drawable.toolbar_stop_normal);
        }
    }

    @Override
    public void onReceivedIcon(WebView view, Bitmap icon)
    {

        super.onReceivedIcon(view, icon);
    }

    @Override
    public void onReceivedTitle(WebView view, String title)
    {
        super.onReceivedTitle(view, title);
    }

}
